home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / graphics / mandlbx1.arc / RAST.C < prev    next >
C/C++ Source or Header  |  1985-11-20  |  2KB  |  71 lines

  1. /* rast.c    PAK    8/86
  2.    save and restore the raster under dialog boxes */
  3.  
  4. /* I would have used vro_cpyfm, but where can I get a hold of the screen MFDB?*/
  5.  
  6. /* note: the notation "alphaPbeta" denotes a dimensional constant which is the
  7.          number of alpha's per beta */
  8.  
  9. #include <osbind.h>
  10.  
  11. struct rast        /* the piece of the screen being saved now */
  12. {    long *Buffer;
  13.     long Hsize, Vsize;
  14.     long *Saddr;
  15.     int bytesPblock;
  16. } rast;
  17.  
  18. rast_save(x0, y0, xw, yw, p, n)
  19. int x0, y0, xw, yw, n;
  20. long *p;
  21. {    long *scr, *screen;
  22.     int i,j;
  23. #    define pixPblock 16
  24. #    define bytesPlong 4
  25. #    define bytesPy 160
  26.                 /* hi(low) res: 640(320) 2(4)-bit pix/line */
  27.     rast.Buffer = p;
  28.     rast.Vsize = yw;
  29.     rast.Saddr=scr=screen= y0*bytesPy + (x0/pixPblock)*rast.bytesPblock 
  30.                       + Logbase(); 
  31.     xw = rast.bytesPblock*(xw/pixPblock +2); /* +1 for each end */
  32.                          /* now # bytes wide*/
  33.     if (xw*yw > n)
  34.         panic("Buffer supplied to Rast: %ld is too small\n",(long)n,0L);
  35.     rast.Hsize = xw /= bytesPlong;        /* now # longs wide */
  36.  
  37.     for (j = yw; j--;)
  38.     {    for (i = xw; i--;)
  39.             *p++ = *scr++;
  40.         scr = screen += bytesPy/bytesPlong;
  41. }    }
  42.  
  43. long
  44. rastSize(x0, y0, xw, yw)
  45. int x0, y0, xw, yw;
  46. {    int i;
  47.  
  48.     xw = xw/pixPblock +2;    /* + one for each end */
  49.                 /*now # blocks wide */
  50.  
  51.     i = Getrez();    /* C-compiler bug -- needs to be previous stmnt*/
  52.     if (i == 2) panic("no support for B/W monitor \n");
  53.     rast.bytesPblock = 8 >> i;     /*lo=8, med=4, hi=2*/
  54.  
  55.      return ((long)xw*rast.bytesPblock*yw);
  56. }
  57.  
  58. rast_restore()
  59. {    long *p, *scr, *screen;
  60.     int i,j, xw;
  61.  
  62.     p =         rast.Buffer;
  63.     scr = screen =     rast.Saddr;
  64.     xw =         rast.Hsize;
  65.  
  66.     for (j = rast.Vsize; j--;)
  67.     {    for (i = xw; i--;)
  68.             *scr++ = *p++;
  69.         scr = screen += bytesPy/bytesPlong;
  70. }    }
  71.